package com.yc.bran.snack.vo;

import com.yc.bran.snack.enums.ResultEnmu;

/*
 * 返回值对象
 */
public class ResultVo<T> {
	private Integer code;
	private String msg;
	private Object data;
	private T datas;

	@Override
	public String toString() {
		return "ResultVo [code=" + code + ", msg=" + msg + ", data=" + data + "]";
	}

	public ResultVo(Integer code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public ResultVo(ResultEnmu enums) {
		super();
		this.code = enums.getCode();
		this.msg = enums.getMsg();
	}

	public ResultVo(ResultEnmu enums, Object data) {
		super();
		this.code = enums.getCode();
		this.msg = enums.getMsg();
		this.data = data;
	}

	public ResultVo(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	public ResultVo() {
		super();
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + ((data == null) ? 0 : data.hashCode());
		result = prime * result + ((msg == null) ? 0 : msg.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ResultVo other = (ResultVo) obj;
		if(code == null) {
			if(other.code != null) 
				return false;
		}else if(!code.equals(other.code)) 
			return false;
		if(data == null) {
			if(other.data != null) 
				return false;
		}else if(!data.equals(other.data)) 
			return false;
		if(msg == null) {
			if(other.msg != null) 
				return false;
		}else if(!msg.equals(other.msg)) 
			return false;
		return true;
	}
}
